<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>展开语法（点语法）</title>
</head>
<body>
    <script>
        // 放
        let arr = [1,2,3];
        let [a,b,c] = [...arr];
        console.log(a,b,c);

        // 收
        let [d,...e] = [1,2,3,4,5,6];
        console.log(e);


        // 求和
        function sum(...args) {
            return args.reduce((a,b) => a += b);
        };
        console.log(sum(1,2,3,4,5,6,7));


        // 商品打折后的价格
        function discount(discount = 0,...products) {
            return products.map(function (value,index) {
                return products[index] * (1 - discount);
            })
        }
        console.log(discount(0.1,99,288,169,398));
    </script>
</body>
</html>